package com.sale.succ.forms;

import com.sale.succ.components.DefForm;
import com.sale.succ.components.DefVerScrollPanel;
import com.sale.succ.datacomp.region.RegionTable;
import com.sale.succ.utils.TraderConstants;
import com.sale.succ.utils.TraderHelper;

import eve.fx.gui.WindowConstants;
import eve.ui.CellPanel;

public class RegionForm extends DefForm {
	private RegionTable regionTable;
	private CellPanel mainPanel;

	public RegionForm() {
		title = TraderHelper.getLabel(TraderConstants.REGIONS);
		addLast(getMainPanel());
		doButtons(CANCELB);
		windowFlagsToSet |= WindowConstants.FLAG_MAXIMIZE;
	}

	private CellPanel getMainPanel() {
		if (mainPanel == null) {
			mainPanel = new CellPanel();
			// mainPanel.addLast(new
			// DefLabel(TraderHelper.getLabel(TraderConstants.SEL_REGION))).setControl(HCENTER).setCell(HGROW);
			DefVerScrollPanel scrollPanel = new DefVerScrollPanel(
					getRegionTable());
			mainPanel.addLast(scrollPanel);

		}
		return mainPanel;
	}

	private RegionTable getRegionTable() {
		if (regionTable == null) {
			regionTable = new RegionTable();
			regionTable.setPreferredSize(40, regionTable.getPrefHeight());

		}
		return regionTable;
	}

}
